<?php

$http_raw_data = @$HTTP_RAW_POST_DATA ? @$HTTP_RAW_POST_DATA : file_get_contents("php://input");

if(!empty($http_raw_data)){

    if (function_exists('json_decode') == true) {
        $ajax_data = json_decode($http_raw_data);
    }

    switch($ajax_data->target){
        case 'destination':


			// get the child resorts
			$params['type_id'] = "2";
			$params['relation_id'] = '12';
			if(!empty($params['relation_id'])){
				$destinations = new destinations();
				$child_resorts = $destinations->get_destinations($params);
			}
			
			// populate the array
			if(!empty($child_resorts)){
				$response = array();
				foreach($child_resorts as $resort_values){
					$response[] = array('key' => $resort_values['name'], 'value' => $resort_values['tree_id'], 'sel' => 0);
				}
			}


		break;
		default:
			$response = null;
		break;
    }
    

    echo json_encode($response);
    exit(1);
}

?>
